package com.neutech.service.impl;

import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.neutech.entity.Grade;
import com.neutech.mapper.GradeMapper;
import com.neutech.service.GradeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 班级表 服务层实现。
 *
 * @author Administrator
 * @since 2025-02-08
 */
@Service
public class GradeServiceImpl extends ServiceImpl<GradeMapper, Grade>  implements GradeService{

    @Override
    public Page<Grade> list(Integer pageNo, Integer pageSize, String name, Integer active) {
        QueryWrapper wrapper = new QueryWrapper();
        if (StringUtils.isNotBlank(name)) {
            wrapper.like("name", name);
        }
        if (null != active) {
            wrapper.eq("active", active);
        }
        wrapper.orderBy("id", false);
        return this.page(new Page<>(pageNo, pageSize), wrapper);
    }

    @Override
    public boolean del(Integer id, Integer active) {
        return this.updateById(new Grade(id, active));
    }

}
